// 2010-03-26 - M. Caputo

#include <QtOpenGL>

#include "WireframeMode.h"

QString WireframeMode::name()
{
	return QString("Wireframe");
}

void WireframeMode::setSettings()
{
	glEnable(GL_DEPTH_TEST);
}

void WireframeMode::unsetSettings()
{
	glDisable(GL_DEPTH_TEST);
}

void WireframeMode::draw(IScene *scene, const QColor & defaultColor)
{
	glColor3f(
		defaultColor.redF(),
		defaultColor.greenF(),
		defaultColor.blueF()
	);
	
	int cp = scene->polygonsCount();
	for(int i=0; i<cp; i++) {
		CPolygon poly = scene->polygon(i);
		int cv = poly.verticesCount();
		glBegin( GL_LINE_LOOP );
			for(int j=0; j<cv; j++) {
				CVertex vert = poly.vertex(j);
				float *data = vert.vertex();
				glVertex3f(
					data[0],
					data[1],
					data[2]
				); 
			}
		glEnd();
	}
}
